<?php 

$sql = "
SELECT
		B.CLASS_NAME	AS TABLE_NAME,
		B.INDEX_NAME	AS INDEX_NAME,
		B.KEY_ORDER		AS COLUMN_POSITION,	
		B.KEY_ATTR_NAME	AS COLUMN_NAME,
		case 
			when C.is_reverse = 'YES' then 'desc'
			else 'asc'
		end AS				DESCEND,
		(
			select 
				case when is_unique  = 'YES' then 'UQ'
				else	''  
				end 
			from db_index where index_name = B.index_name
		)	AS UQ,
		(
			select 
				case when is_primary_key  = 'YES' then 'PK'
				else	''  
				end 
			from db_index where index_name = B.index_name
		)	as PK,
		''	as INDEX_TYPE,
		'N'	as ISNULL,
		''	as COMMENT
FROM 
	 db_index_key B left outer join db_index C on (B.index_name = C.index_name)
where 
	B.CLASS_NAME = '{$param['object']}' 
order by 
	B.INDEX_NAME, B.KEY_ORDER

";

return $sql;

?>